home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performRebuildSurface.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  30.5 KB  |  1,002 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Mar 14, 1997
  22. //
  23. //  Description:
  24. //      This script is defines the option box for the rebuild surface menu item.
  25. //
  26.  
  27.  
  28. //
  29. //  Procedure Name:
  30. //      setOptionVars
  31. //
  32. //  Description:
  33. //        Initialize the option values.
  34. //
  35. //  Input Arguments:
  36. //        Whether to set the options to default values.
  37. //
  38. //  Return Value:
  39. //      None.
  40. //
  41. proc setOptionVars(int $forceFactorySettings)
  42. {
  43.     rebuildSurfaceSetOptionVars( $forceFactorySettings );
  44. }
  45.  
  46. //
  47. //  Procedure Name:
  48. //      rebuildSurfaceVisibility
  49. //
  50. //  Description:
  51. //        Depending on the options, some other options do or do not show.
  52. //
  53. //  Input Arguments:
  54. //      parent               - Top level parent layout of the option box UI.
  55. //                             Required so that UI object names can be 
  56. //                             successfully resolved.
  57. //  Return Value:
  58. //      None.
  59. //
  60.  
  61. proc int getRebuildType()
  62. // Description:
  63. //     Return the "1" based rebuild type.
  64. {
  65.     int $rebType = `radioButtonGrp -q -select rebuildTypeRadioGroup1`;
  66.     if( 0 == $rebType ) {
  67.         $rebType = `radioButtonGrp -q -sl rebuildTypeRadioGroup2`;
  68.         if( 0 == $rebType ) {
  69.             $rebType = `radioButtonGrp -q -sl rebuildTypeRadioGroup3`;
  70.             if( 0 == $rebType ) {
  71.                 if( 1 == `radioButtonGrp -q -nrb rebuildTypeRadioGroup4` ){
  72.                     $rebType = 2;
  73.                 }
  74.                 else {
  75.                     $rebType = `radioButtonGrp -q -sl rebuildTypeRadioGroup4`;
  76.                 }
  77.  
  78.                 $rebType += 2;
  79.             }
  80.             $rebType += 2;
  81.         }
  82.         $rebType += 2;
  83.     }
  84.  
  85.     return $rebType;
  86. }
  87.  
  88. global proc rebuildSurfaceVisibility( string $parent,
  89.                                       int $useGlobalTol,
  90.                                       int $rebuildType,
  91.                                       int $keepCVs,
  92.                                       int $keepNumSpans )
  93. {
  94.     if( $useGlobalTol < 0 ) {
  95.         $useGlobalTol = `radioButtonGrp -q -select toleranceRadioButtonGrp`;
  96.     }
  97.     if( $rebuildType < 0 ) {
  98.         $rebuildType = getRebuildType();
  99.     }
  100.     if( $keepCVs < 0 ) {
  101.         $keepCVs = `checkBoxGrp -q -v2 keepCheckBoxGrp`;
  102.     }
  103.     if( $keepNumSpans < 0 ) {
  104.         $keepNumSpans = `checkBoxGrp -q -v3 keepCheckBoxGrp`;
  105.     }
  106.     // can only show slider of not keeping CVs or numSpans
  107.     int $showCVslider = ((!$keepCVs) && (!$keepNumSpans));
  108.  
  109.     switch( $rebuildType ) {
  110.       case 1:
  111.       default:
  112.         // Uniform (0 for the attribute)
  113.         intSliderGrp -e -en ($showCVslider) numSpansUIntSliderGrp;
  114.         intSliderGrp -e -en ($showCVslider) numSpansVIntSliderGrp;
  115.         checkBoxGrp -e -en true keepCheckBoxGrp;
  116.         checkBoxGrp -e -en1 (!$keepCVs) -en2 true -en3 (!$keepCVs) keepCheckBoxGrp;
  117.         radioButtonGrp -e -en true directionRadioButtonGrp;
  118.  
  119.         frameLayout -e -collapse false uniformTypeLayout;
  120.         frameLayout -e -collapse true toleranceLayout;
  121.         frameLayout -e -collapse true endKnotsLayout;
  122.         break;
  123.  
  124.       case 2:
  125.         // Reduce (1 for the attribute)
  126.         checkBoxGrp -e -en false keepCheckBoxGrp;
  127.  
  128.         frameLayout -e -collapse true uniformTypeLayout;
  129.         frameLayout -e -collapse false toleranceLayout;
  130.         radioButtonGrp -e -en true directionRadioButtonGrp;
  131.         if( $useGlobalTol == 1 ) {
  132.             tabLayout -e -selectTab globalToleranceNoSlider
  133.                 localToleranceTabLayout;
  134.         }
  135.         else {
  136.             tabLayout -e -selectTab localToleranceSlider 
  137.                 localToleranceTabLayout;
  138.         }
  139.         frameLayout -e -collapse true endKnotsLayout;
  140.         break;
  141.  
  142.       case 3:
  143.         // Match (2 for the attribute)
  144.         checkBoxGrp -e -en true keepCheckBoxGrp;
  145.         // keep numspans must be disabled for match knots
  146.         checkBoxGrp -e -en1 true -en2 true -en3 false keepCheckBoxGrp;
  147.  
  148.         radioButtonGrp -e -en true directionRadioButtonGrp;
  149.  
  150.         frameLayout -e -collapse true uniformTypeLayout;
  151.         frameLayout -e -collapse true toleranceLayout;
  152.         frameLayout -e -collapse true endKnotsLayout;
  153.         break;
  154.  
  155.       case 4:
  156.         // Remove multiple (3 for the attribute)
  157.         checkBoxGrp -e -en false keepCheckBoxGrp;
  158.         // no direction option for nonrational - always does both
  159.         radioButtonGrp -e -en false directionRadioButtonGrp;
  160.  
  161.         frameLayout -e -collapse true uniformTypeLayout;
  162.         frameLayout -e -collapse true toleranceLayout;
  163.         frameLayout -e -collapse true endKnotsLayout;
  164.         break;
  165.  
  166.       case 5:
  167.         // force non-rational (4 for the attribute)
  168.         checkBoxGrp -e -en false keepCheckBoxGrp;
  169.  
  170.         // no direction option for no mult - always does both
  171.         radioButtonGrp -e -en false directionRadioButtonGrp;
  172.  
  173.         frameLayout -e -collapse true uniformTypeLayout;
  174.         frameLayout -e -collapse false toleranceLayout;
  175.         if( $useGlobalTol == 1 ) {
  176.             tabLayout -e -selectTab globalToleranceNoSlider
  177.                 localToleranceTabLayout;
  178.         }
  179.         else {
  180.             tabLayout -e -selectTab localToleranceSlider 
  181.                 localToleranceTabLayout;
  182.         }
  183.         frameLayout -e -collapse true endKnotsLayout;
  184.         break;
  185.  
  186.       case 6:
  187.         // rebuild ends (5 for the attribute)
  188.         checkBoxGrp -e -en false keepCheckBoxGrp;
  189.         radioButtonGrp -e -en true directionRadioButtonGrp;
  190.  
  191.         frameLayout -e -collapse true uniformTypeLayout;
  192.         frameLayout -e -collapse true toleranceLayout;
  193.         frameLayout -e -collapse false endKnotsLayout;
  194.         break;
  195.  
  196.       case 7:
  197.         // trim convert (6 for the attribute)
  198.         intSliderGrp -e -en true numSpansUIntSliderGrp;
  199.         intSliderGrp -e -en true numSpansVIntSliderGrp;
  200.         checkBoxGrp -e -en true keepCheckBoxGrp;
  201.         checkBoxGrp -e -en1 false -en2 false -en3 true keepCheckBoxGrp;
  202.         radioButtonGrp -e -en false directionRadioButtonGrp;
  203.  
  204.         frameLayout -e -collapse false uniformTypeLayout;
  205.         frameLayout -e -collapse true toleranceLayout;
  206.         frameLayout -e -collapse true endKnotsLayout;
  207.         break;
  208.  
  209.       case 8:
  210.         // bezier (7 for the attribute)
  211.         intSliderGrp -e -en ($showCVslider) numSpansUIntSliderGrp;
  212.         intSliderGrp -e -en ($showCVslider) numSpansVIntSliderGrp;
  213.         checkBoxGrp -e -en true keepCheckBoxGrp;
  214.         checkBoxGrp -e -en1 false -en2 false -en3 true keepCheckBoxGrp;
  215.         radioButtonGrp -e -en false directionRadioButtonGrp;
  216.  
  217.         frameLayout -e -collapse false uniformTypeLayout;
  218.         frameLayout -e -collapse true toleranceLayout;
  219.         frameLayout -e -collapse true endKnotsLayout;
  220.         break;
  221.  
  222.     }
  223. }
  224.  
  225. //
  226. //  Procedure Name:
  227. //      rebuildSurfaceSetup
  228. //
  229. //  Description:
  230. //        Update the state of the option box UI to reflect the option values.
  231. //
  232. //  Input Arguments:
  233. //      parent               - Top level parent layout of the option box UI.
  234. //                             Required so that UI object names can be 
  235. //                             successfully resolved.
  236. //
  237. //        forceFactorySettings - Whether the option values should be set to
  238. //                             default values.
  239. //
  240. //  Return Value:
  241. //      None.
  242. //
  243.  
  244. global proc rebuildSurfaceSetup( string $parent,
  245.                                  int $forceFactorySettings,
  246.                                  string $goToTool )
  247. {
  248.     //    Retrieve the option settings
  249.     //
  250.     setOptionVars($forceFactorySettings);
  251.     rebuildSurfaceToolSetup( $forceFactorySettings, $goToTool );
  252.  
  253.     setParent $parent;
  254.  
  255.     //    Query the optionVar's and set the values into the controls.
  256.  
  257.     // Query the optionVar's and set the values into the controls
  258.     //
  259.     int $rebuildType = `optionVar -q rebuildSurfaceType` + 1;
  260.     int $numSpansU = `optionVar -q rebuildSurfaceTypeUniformNumSpansU`;
  261.     int $numSpansV = `optionVar -q rebuildSurfaceTypeUniformNumSpansV`;
  262.     int $degreeU = `optionVar -q rebuildSurfaceTypeUniformDegreeU`;
  263.     int $degreeV = `optionVar -q rebuildSurfaceTypeUniformDegreeV`;
  264.     int $keepRange = `optionVar -q rebuildSurfaceKeepRange`;
  265.     int $direction = `optionVar -q rebuildSurfaceDirection`;
  266.     int $endKnots = `optionVar -q rebuildSurfaceEndKnots`;
  267.     int $keepControlPoints = `optionVar -q rebuildSurfaceKeepControlPoints`;
  268.     int $keepCornerPts = `optionVar -q rebuildSurfaceKeepCornerPoints`;
  269.     int $keepNumSpans = `optionVar -q rebuildSurfaceKeepNumSpans`;
  270.     int $useGlobalTol = `optionVar -q rebuildSurfaceUseGlobalTolerance`;
  271.     radioButtonGrp -e -select (2 - $useGlobalTol) toleranceRadioButtonGrp;
  272.  
  273.     float $localTol = `optionVar -q rebuildSurfaceLocalTolerance`;
  274.     int $keepOriginal = `optionVar -q rebuildSurfaceKeepOriginal`;
  275.     int $polys = `optionVar -q rebuildSurfacePolys`;
  276.  
  277.     // Set the controls
  278.     //
  279.     if( (1 == $rebuildType) || (2 == $rebuildType) ) {
  280.         radioButtonGrp -e -select $rebuildType rebuildTypeRadioGroup1;
  281.     }
  282.     else if( $rebuildType == 3 || $rebuildType == 4 ) {
  283.         int $temp = $rebuildType - 2;
  284.         radioButtonGrp -e -select $temp rebuildTypeRadioGroup2;
  285.     }
  286.     else if( $rebuildType == 5 || $rebuildType == 6 ) {
  287.         int $temp = $rebuildType - 4;
  288.         radioButtonGrp -e -select $temp rebuildTypeRadioGroup3;
  289.     }
  290.     else {
  291.         int $temp = $rebuildType - 6;
  292.         if( 1 == `radioButtonGrp -q -nrb rebuildTypeRadioGroup4` ) {
  293.             $temp = 1;
  294.             optionVar -iv rebuildSurfaceType 7;
  295.         }
  296.         radioButtonGrp -e -select $temp rebuildTypeRadioGroup4;
  297.     }
  298.     intSliderGrp -e -value $numSpansU numSpansUIntSliderGrp;
  299.     intSliderGrp -e -value $numSpansV numSpansVIntSliderGrp;
  300.  
  301.     switch($degreeU) {
  302.         case 1: radioButtonGrp -e -select 1 rebuildSrfUDegree123; break;
  303.         case 2: radioButtonGrp -e -select 2 rebuildSrfUDegree123; break;
  304.         case 3: radioButtonGrp -e -select 3 rebuildSrfUDegree123; break;
  305.         case 5: radioButtonGrp -e -select 1 rebuildSrfUDegree57; break;
  306.         case 7: radioButtonGrp -e -select 2 rebuildSrfUDegree57; break;
  307.         case 0: radioButtonGrp -e -select 3 rebuildSrfUDegree57; break;
  308.         default: radioButtonGrp -e -select 3 rebuildSrfUDegree123; break;
  309.     }
  310.     switch($degreeV) {
  311.         case 1: radioButtonGrp -e -select 1 rebuildSrfVDegree123; break;
  312.         case 2: radioButtonGrp -e -select 2 rebuildSrfVDegree123; break;
  313.         case 3: radioButtonGrp -e -select 3 rebuildSrfVDegree123; break;
  314.         case 5: radioButtonGrp -e -select 1 rebuildSrfVDegree57; break;
  315.         case 7: radioButtonGrp -e -select 2 rebuildSrfVDegree57; break;
  316.         case 0: radioButtonGrp -e -select 3 rebuildSrfVDegree57; break;
  317.         default: radioButtonGrp -e -select 3 rebuildSrfVDegree123; break;
  318.     }
  319.  
  320.     radioButtonGrp -e -select ($endKnots+1) endKnotsRadioButtonGrp;
  321.     radioButtonGrp -e -select ($keepRange+1) keepRangeRadioButtonGrp;
  322.     radioButtonGrp -e -select ($direction+1) directionRadioButtonGrp;
  323.     checkBoxGrp -e -value1 $keepCornerPts keepCheckBoxGrp;
  324.     checkBoxGrp -e -value2 $keepControlPoints keepCheckBoxGrp;
  325.     checkBoxGrp -e -value3 $keepNumSpans keepCheckBoxGrp;
  326.     radioButtonGrp -e -select $useGlobalTol toleranceRadioButtonGrp;
  327.     floatSliderGrp -e -value $localTol localTolFloatFieldGrp;
  328.     checkBoxGrp -e -value1 $keepOriginal keepOriginalCheckBox;
  329.  
  330.     // No "Bezier" option on the geometry output, as you just
  331.     // want the NURBS that is rebuilt as Bezier.
  332.     if( 3 == $polys ) $polys = 0;
  333.     radioButtonGrp -edit -select ($polys+1) outputPolyRadioButtonGrp;
  334.  
  335.     // Nurbs or poly ?
  336.     //
  337.     switch( $polys ) {
  338.       case 0:
  339.       default:
  340.         frameLayout -e -cl false geomOptionLN;
  341.         frameLayout -e -cl true geomOptionLP;
  342.         frameLayout -e -cl true geomOptionLS;
  343.         break;
  344.       case 1:
  345.         frameLayout -e -cl true geomOptionLN;
  346.         frameLayout -e -cl false geomOptionLP;
  347.         frameLayout -e -cl true geomOptionLS;
  348.         break;
  349.       case 2:
  350.         frameLayout -e -cl true geomOptionLN;
  351.         frameLayout -e -cl true geomOptionLP;
  352.         frameLayout -e -cl false geomOptionLS;
  353.         break;
  354.     }
  355.  
  356.     nurbsToPolySetup( $parent, $forceFactorySettings );
  357.     nurbsToSubdivSetup( $parent, $forceFactorySettings );
  358.  
  359.     rebuildSurfaceVisibility $parent $useGlobalTol
  360.         $rebuildType $keepControlPoints $keepNumSpans;
  361.  
  362.     if( "" != $goToTool ) { 
  363.         checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
  364.           scriptToolExtraWidget;
  365.         checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
  366.           scriptToolExtraWidget;
  367.     }
  368. }
  369.  
  370. //
  371. //  Procedure Name:
  372. //      rebuildSurfaceCallback
  373. //
  374. //  Description:
  375. //        Update the option values with the current state of the option box UI.
  376. //
  377. //  Input Arguments:
  378. //      parent - Top level parent layout of the option box UI.  Required so
  379. //               that UI object names can be successfully resolved.
  380. //
  381. //        doIt   - Whether the command should execute.
  382. //
  383. //  Return Value:
  384. //      None.
  385. //
  386.  
  387. global proc rebuildSurfaceCallback( string $parent,
  388.                                     int $doIt,
  389.                                     string $goToTool )
  390. {
  391.     setParent $parent;
  392.  
  393.     // Set the optionVar's from the current control values, and then perform 
  394.     // the command
  395.     //
  396.     int $rebuildType = getRebuildType();
  397.  
  398.     int $numSpansU = `intSliderGrp -q -value numSpansUIntSliderGrp`;
  399.     int $numSpansV = `intSliderGrp -q -value numSpansVIntSliderGrp`;
  400.  
  401.     int $degreeBtn123 = `radioButtonGrp -q -select rebuildSrfUDegree123`;
  402.     int $degreeBtn57 = `radioButtonGrp -q -select rebuildSrfUDegree57`;
  403.     int $degreeU;
  404.     switch($degreeBtn123) {
  405.       case 1: $degreeU = 1; break;
  406.       case 2: $degreeU = 2; break;
  407.       case 3: $degreeU = 3; break;
  408.       default:
  409.         switch($degreeBtn57) {
  410.           case 1: $degreeU = 5; break;
  411.           case 2: $degreeU = 7; break;
  412.           case 3: $degreeU = 0; break;
  413.           default: $degreeU = 3; break;
  414.         }
  415.         break;
  416.     }
  417.  
  418.     $degreeBtn123 = `radioButtonGrp -q -select rebuildSrfVDegree123`;
  419.     $degreeBtn57 = `radioButtonGrp -q -select rebuildSrfVDegree57`;
  420.     int $degreeV;
  421.     switch($degreeBtn123) {
  422.       case 1: $degreeV = 1; break;
  423.       case 2: $degreeV = 2; break;
  424.       case 3: $degreeV = 3; break;
  425.       default:
  426.         switch($degreeBtn57) {
  427.           case 1: $degreeV = 5; break;
  428.           case 2: $degreeV = 7; break;
  429.           case 3: $degreeV = 0; break;
  430.           default: $degreeV = 3; break;
  431.         }
  432.         break;
  433.     }
  434.  
  435.     int $endKnots = `radioButtonGrp -q -select endKnotsRadioButtonGrp` - 1;
  436.     int $keepRange = `radioButtonGrp -q -select keepRangeRadioButtonGrp` - 1;
  437.     int $direction = `radioButtonGrp -q -select directionRadioButtonGrp` - 1;
  438.     int $keepCornerPts = `checkBoxGrp -q -v1 keepCheckBoxGrp`;
  439.     int $keepControlPoints = `checkBoxGrp -q -v2 keepCheckBoxGrp`;
  440.     int $keepNumSpans = `checkBoxGrp -q -v3 keepCheckBoxGrp`;
  441.     int $useGlobalTol = 2 - `radioButtonGrp -q -select toleranceRadioButtonGrp`;
  442.     float $localtol = `floatSliderGrp -q -value localTolFloatFieldGrp`;
  443.     int $keepOrig = `checkBoxGrp -q -v1 keepOriginalCheckBox`;
  444.     int $polygons = `radioButtonGrp -q -select outputPolyRadioButtonGrp` - 1;
  445.  
  446.     optionVar -intValue rebuildSurfaceType ($rebuildType-1);
  447.     optionVar -intValue rebuildSurfaceTypeUniformNumSpansU $numSpansU;
  448.     optionVar -intValue rebuildSurfaceTypeUniformNumSpansV $numSpansV;
  449.     optionVar -intValue rebuildSurfaceTypeUniformDegreeU $degreeU;
  450.     optionVar -intValue rebuildSurfaceTypeUniformDegreeV $degreeV;
  451.     optionVar -intValue rebuildSurfaceEndKnots $endKnots;
  452.     optionVar -intValue rebuildSurfaceKeepRange $keepRange;
  453.     optionVar -intValue rebuildSurfaceDirection $direction;
  454.     optionVar -intValue rebuildSurfaceKeepControlPoints $keepControlPoints;
  455.     optionVar -intValue rebuildSurfaceKeepCornerPoints $keepCornerPts;
  456.     optionVar -intValue rebuildSurfaceKeepNumSpans $keepNumSpans;
  457.     optionVar -intValue rebuildSurfaceUseGlobalTolerance $useGlobalTol;
  458.     optionVar -floatValue rebuildSurfaceLocalTolerance $localtol;
  459.     optionVar -intValue rebuildSurfaceKeepOriginal $keepOrig;
  460.     optionVar -intValue rebuildSurfacePolys $polygons;
  461.  
  462.     nurbsToPolyCallback( $parent, 0 );
  463.     nurbsToSubdivCallback( $parent, 0 );
  464.  
  465.     if( 1 == $doIt ) {
  466.         performRebuildSurface( 0, $goToTool ); 
  467.         string $tmpCmd = "performRebuildSurface( 0, \"" + $goToTool + "\")";
  468.         addToRecentCommandQueue $tmpCmd "Rebuild Surfaces";
  469.     }
  470.     else if( $doIt ) {
  471.         setToolTo $goToTool;
  472.     }
  473. }
  474.  
  475. //
  476. //  Procedure Name:
  477. //      rebuildSurfaceOptions
  478. //
  479. //  Description:
  480. //        Construct the option box UI.  Involves accessing the standard option
  481. //        box and customizing the UI accordingly.
  482. //
  483. //  Input Arguments:
  484. //      None.
  485. //
  486. //  Return Value:
  487. //      None.
  488. //
  489.  
  490. proc rebuildSurfaceOptions( int $inTheTool, string $goToTool )
  491. {
  492.     //    Name of the command for this option box.
  493.     //
  494.     string $commandName = "rebuildSurface";
  495.  
  496.     //    Build the option box actions.
  497.     //
  498.     string $callback = ($commandName + "Callback");
  499.     string $setup = ($commandName + "Setup");
  500.  
  501.     global string $gOptionBoxActionToolItem;
  502.     $gOptionBoxActionToolItem = "modelWithToolRebuildSurface";
  503.     global string $gOptionBoxActionToolItemCB;
  504.     $gOptionBoxActionToolItemCB = "rebuildSurfaceToolScript 3";
  505.  
  506.     //    Step 1:  Get the option box.
  507.     //    ============================
  508.     string $layout = getOptionBox();
  509.     setParent $layout;
  510.     
  511.     //    Step 2:  Pass the command name to the option box.
  512.     //    =================================================
  513.     setOptionBoxCommandName($commandName);
  514.     
  515.     //    Step 3:  Activate the default UI template.
  516.     //    ==========================================
  517.     setUITemplate -pushTemplate DefaultTemplate;
  518.  
  519.     //    Step 4: Create option box contents.
  520.     //    ===================================
  521.     
  522.     //    Turn on the wait cursor.
  523.     //
  524.     waitCursor -state 1;
  525.  
  526.     tabLayout -scr true -tv false;
  527.     
  528.     string $parent = `columnLayout -adjustableColumn 1`;
  529.     
  530.     radioButtonGrp
  531.         -numberOfRadioButtons 2
  532.         -label "Rebuild Type" 
  533.         -label1 "Uniform"
  534.         -label2 "Reduce"
  535.         rebuildTypeRadioGroup1;
  536.         
  537.     radioButtonGrp -shareCollection rebuildTypeRadioGroup1
  538.         -numberOfRadioButtons 2
  539.         -label ""
  540.         -label1 "Match Knots"
  541.         -label2 "No Multiple Knots"
  542.         rebuildTypeRadioGroup2;
  543.         
  544.     radioButtonGrp -shareCollection rebuildTypeRadioGroup1
  545.         -numberOfRadioButtons 2
  546.         -label ""
  547.         -label1 "Non-Rational"
  548.         -label2 "End Conditions"
  549.         rebuildTypeRadioGroup3;
  550.         
  551.     int $hasTrimConvert = `licenseCheck -m edit -typ model`;
  552.     if( $hasTrimConvert ) {
  553.         radioButtonGrp -shareCollection rebuildTypeRadioGroup1
  554.             -numberOfRadioButtons 2
  555.             -label ""
  556.             -label1 "Trim Convert"
  557.             -label2 "Bezier"
  558.             rebuildTypeRadioGroup4;
  559.     }
  560.     else {
  561.         radioButtonGrp -shareCollection rebuildTypeRadioGroup1
  562.             -numberOfRadioButtons 1
  563.             -label ""
  564.             -label1 "Bezier"
  565.             rebuildTypeRadioGroup4;
  566.     }
  567.  
  568.     separator;
  569.  
  570.     // tab for end conditions
  571.     frameLayout -bv false -bs "in" -lv false endKnotsLayout;
  572.         columnLayout endKnotsGroups;
  573.             radioButtonGrp
  574.                 -numberOfRadioButtons 2
  575.                 -label "End conditions"
  576.                 -label1 "No Multiple knots"
  577.                 -label2 "Multiple knots"
  578.                 endKnotsRadioButtonGrp;
  579.         setParent ..;
  580.     setParent ..;
  581.  
  582.     radioButtonGrp -nrb 3 -l "Parameter Range"
  583.         -l1 "0 to 1"
  584.         -l2 "Keep"
  585.         -l3 "0 to #Spans"
  586.         keepRangeRadioButtonGrp;
  587.  
  588.     radioButtonGrp -nrb 3 -label "Direction"
  589.         -label1 "U" -label2 "V" -label3 "U and V" directionRadioButtonGrp;
  590.         
  591.     checkBoxGrp -ncb 3 -l "Keep"
  592.         -l1 "Corners"
  593.         -l2 "CVs"
  594.         -l3 "NumSpans"
  595.         -on2 ("rebuildSurfaceVisibility " + $parent + " -1 -1  1 -1")
  596.         -of2 ("rebuildSurfaceVisibility " + $parent + " -1 -1  0 -1")
  597.         -on3 ("rebuildSurfaceVisibility " + $parent + " -1 -1 -1  1")
  598.         -of3 ("rebuildSurfaceVisibility " + $parent + " -1 -1 -1  0")
  599.         keepCheckBoxGrp;
  600.         
  601.     frameLayout -bv false -bs "in" -lv false uniformTypeLayout;
  602.         columnLayout uniformTypeSliders;
  603.             intSliderGrp -label "Number of Spans U" 
  604.                 -min 0 -max 100 -fmx 500 -field on numSpansUIntSliderGrp;
  605.             intSliderGrp -label "Number of Spans V" 
  606.                 -min 0 -max 100 -fmx 500 -field on numSpansVIntSliderGrp;
  607.  
  608.             radioButtonGrp -label "Degree U"
  609.                 -numberOfRadioButtons 3
  610.                 -l1 "1 Linear"
  611.                 -l2 "2" // Quadratic
  612.                 -l3 "3 Cubic"
  613.                 -select 3
  614.                 rebuildSrfUDegree123;
  615.             radioButtonGrp -shareCollection rebuildSrfUDegree123
  616.                 -numberOfRadioButtons 3
  617.                 -l1 "5" // Quintic
  618.                 -l2 "7"
  619.                 -l3 "Original"
  620.                 rebuildSrfUDegree57;
  621.  
  622.             radioButtonGrp -label "Degree V"
  623.                 -numberOfRadioButtons 3
  624.                 -l1 "1 Linear"
  625.                 -l2 "2" // Quadratic
  626.                 -l3 "3 Cubic"
  627.                 -select 3
  628.                 rebuildSrfVDegree123;
  629.             radioButtonGrp -shareCollection rebuildSrfVDegree123
  630.                 -numberOfRadioButtons 3
  631.                 -l1 "5" // Quintic
  632.                 -l2 "7"
  633.                 -l3 "Original"
  634.                 rebuildSrfVDegree57;
  635.  
  636.         setParent ..;
  637.     setParent ..;
  638.         
  639.     separator;
  640.     checkBoxGrp -ncb 1 -l1 "Keep Original" keepOriginalCheckBox;
  641.  
  642.     frameLayout -bv false -bs "in" -lv false toleranceLayout;
  643.         columnLayout toleranceGroups;
  644.             radioButtonGrp
  645.                 -numberOfRadioButtons 2
  646.                 -label "Use Tolerance"
  647.                 -label1 "Global"
  648.                 -label2 "Local"
  649.                 toleranceRadioButtonGrp;
  650.         
  651.             tabLayout -tabsVisible false localToleranceTabLayout;
  652.                 columnLayout globalToleranceNoSlider;
  653.                 setParent ..;
  654.                 columnLayout localToleranceSlider;
  655.                     floatSliderGrp -label "Positional Tolerance" 
  656.                         -min 0.001 -max 1.0 -fmn 0.00001 -fmx 1000.0
  657.                         localTolFloatFieldGrp;
  658.                 setParent ..;
  659.             setParent ..;
  660.         setParent ..;
  661.     setParent ..;
  662.  
  663.     // Set the tolerance radio button up so that when "Global" is
  664.     // selected, then the local tolerance slider is disabled.
  665.     // When "Local" is selected then the local tolerance slider is enabled.
  666.     //
  667.     radioButtonGrp -e
  668.         -cc1 ("rebuildSurfaceVisibility " + $parent + " 1 -1 -1 -1")
  669.         -cc2 ("rebuildSurfaceVisibility " + $parent + " 0 -1 -1 -1")
  670.         toleranceRadioButtonGrp;
  671.  
  672.     // Set the layout that contains the number of spans slider and 
  673.     // the degree slider so that only displays stuff when the type is Uniform.
  674.     //
  675.     radioButtonGrp -e
  676.         -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 1 -1 -1")
  677.         -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 2 -1 -1")
  678.         rebuildTypeRadioGroup1;
  679.     radioButtonGrp -e
  680.         -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 3 -1 -1")
  681.         -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 4 -1 -1")
  682.         rebuildTypeRadioGroup2;
  683.     radioButtonGrp -e
  684.         -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 5 -1 -1")
  685.         -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 6 -1 -1")
  686.         rebuildTypeRadioGroup3;
  687.  
  688.     if( $hasTrimConvert ) {
  689.         radioButtonGrp -e
  690.             -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 7 -1 -1")
  691.             -cc2 ("rebuildSurfaceVisibility " + $parent + " -1 8 -1 -1")
  692.             rebuildTypeRadioGroup4;
  693.     }
  694.     else {
  695.         radioButtonGrp -e
  696.             -cc1 ("rebuildSurfaceVisibility " + $parent + " -1 8 -1 -1")
  697.             rebuildTypeRadioGroup4;
  698.     }
  699.  
  700.     if( `isTrue "SubdivUIExists"` ) {
  701.         radioButtonGrp -numberOfRadioButtons 3
  702.           -label "Output Geometry"
  703.           -label1 "Nurbs"
  704.           -label2 "Polygons"
  705.           -label3 "Subdiv"
  706.           -cc1 ("frameLayout -e -cl false geomOptionLN; " +
  707.                 "frameLayout -e -cl true geomOptionLP; " +
  708.                 "frameLayout -e -cl true geomOptionLS;")
  709.           -cc2 ("frameLayout -e -cl true geomOptionLN; " +
  710.                 "frameLayout -e -cl false geomOptionLP; " +
  711.                 "frameLayout -e -cl true geomOptionLS;")
  712.           -cc3 ("frameLayout -e -cl true geomOptionLN; " +
  713.                 "frameLayout -e -cl true geomOptionLP; " +
  714.                 "frameLayout -e -cl false geomOptionLS;")
  715.           outputPolyRadioButtonGrp;
  716.     }
  717.     else {
  718.         radioButtonGrp -numberOfRadioButtons 2
  719.           -label "Output Geometry"
  720.           -label1 "Nurbs"
  721.           -label2 "Polygons"
  722.           -cc1 ("frameLayout -e -cl false geomOptionLN; " +
  723.                 "frameLayout -e -cl true geomOptionLP; " +
  724.                 "frameLayout -e -cl true geomOptionLS;")
  725.           -cc2 ("frameLayout -e -cl true geomOptionLN; " +
  726.                 "frameLayout -e -cl false geomOptionLP; " +
  727.                 "frameLayout -e -cl true geomOptionLS;")
  728.           outputPolyRadioButtonGrp;
  729.     }
  730.  
  731.     string $par;
  732.     frameLayout -bv false -bs "in" -lv false geomOptionLP;
  733.         $par = `columnLayout geomOptionP`;
  734.         nurbsToPolyAddOptions $par;
  735.         setParent ..;
  736.     setParent ..;
  737.     frameLayout -bv false -bs "in" -lv false geomOptionLN;
  738.         columnLayout geomOptionN;
  739.         setParent ..;
  740.     setParent ..;
  741.     frameLayout -bv false -bs "in" -lv false geomOptionLS;
  742.         $par = `columnLayout geomOptionS`;
  743.         nurbsToSubdivAddOptions $par;
  744.         setParent ..;
  745.     setParent ..;
  746.  
  747.     if( $inTheTool ) {
  748.         separator;
  749.         checkBoxGrp -ncb 2 -l "Tool Behavior"
  750.           -l1 "Exit on Completion"
  751.           -v1 off
  752.           -on1 ("scriptCtx -e -euc true " + $goToTool)
  753.           -of1 ("scriptCtx -e -euc false " + $goToTool)
  754.  
  755.           -l2 "Auto Completion"
  756.           -v2 on
  757.           -on2 ("scriptCtx -e -lac true " + $goToTool)
  758.           -of2 ("scriptCtx -e -lac false " + $goToTool)
  759.           scriptToolExtraWidget;
  760.     }
  761.  
  762.     //    Turn off the wait cursor.
  763.     //
  764.     waitCursor -state 0;
  765.     
  766.     //    Step 5: Deactivate the default UI template.
  767.     //  ===========================================
  768.     //
  769.     setUITemplate -popTemplate;
  770.  
  771.     //    Step 6: Customize the buttons.  
  772.     //    ==============================
  773.  
  774.     //    'Apply' button.
  775.     //
  776.     string $applyBtn = getOptionBoxApplyBtn();
  777.     if( $inTheTool ) {
  778.         button -edit -l "Rebuild Tool"
  779.             -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
  780.             $applyBtn;
  781.     }
  782.     else {
  783.         button -edit -l "Rebuild"
  784.             -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
  785.             $applyBtn;
  786.     }
  787.  
  788.     //    'Save' button.
  789.     //
  790.     string $saveBtn = getOptionBoxSaveBtn();
  791.     button -e 
  792.         -command ($callback + " " + $parent + " 0 \"" +
  793.                   $goToTool + "\"; hideOptionBox")
  794.         $saveBtn;
  795.  
  796.     //    'Reset' button.
  797.     //
  798.     string $resetBtn = getOptionBoxResetBtn();
  799.     button -e 
  800.         -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
  801.         $resetBtn;
  802.  
  803.     //    Step 7: Set the option box title.
  804.     //    =================================
  805.     //
  806.     if( $inTheTool ) {
  807.         setOptionBoxTitle("Rebuild Surface Tool Options");
  808.     }
  809.     else {
  810.         setOptionBoxTitle("Rebuild Surface Options");
  811.     }
  812.  
  813.     //    Step 8: Customize the 'Help' menu item text.
  814.     //    ============================================
  815.     //
  816.     setOptionBoxHelpTag( "RebuildSurfaces" );
  817.  
  818.     //    Step 9: Set the current values of the option box.
  819.     //    =================================================
  820.     //
  821.     eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");    
  822.     
  823.     //    Step 10: Show the option box.
  824.     //    =============================
  825.     //
  826.     showOptionBox();
  827. }
  828.  
  829. //
  830. //  Procedure Name:
  831. //      rebuildSurfaceHelp
  832. //
  833. //  Description:
  834. //        Return a short description about this command.
  835. //
  836. //  Input Arguments:
  837. //      None.
  838. //
  839. //  Return Value:
  840. //      string.
  841. //
  842.  
  843. proc string rebuildSurfaceHelp()
  844. {
  845.     return 
  846.     "  Command: Rebuild Surface - perform surface rebuild\n" +
  847.     "Selection: surface";    
  848. }
  849.  
  850. global proc performRebuildSurfacePreset()
  851. {
  852.     rebuildSurfaceSetOptionVars( false );
  853.  
  854.     int $doHistory = `constructionHistory -q -tgl`;
  855.     int $replaceOriginal = !`optionVar -q rebuildSurfaceKeepOriginal`;
  856.     int $rebuildType = `optionVar -q rebuildSurfaceType`;
  857.     float $globalTol = `optionVar -q positionalTolerance`;
  858.  
  859.     int $srfNumSpansU = `optionVar -q rebuildSurfaceTypeUniformNumSpansU`;
  860.     int $srfNumSpansV = `optionVar -q rebuildSurfaceTypeUniformNumSpansV`;
  861.     int $srfDegreeU = `optionVar -q rebuildSurfaceTypeUniformDegreeU`;
  862.     int $srfDegreeV = `optionVar -q rebuildSurfaceTypeUniformDegreeV`;
  863.     int $keepParmRange = `optionVar -q rebuildSurfaceKeepRange`;
  864.     int $endKnots = `optionVar -q rebuildSurfaceEndKnots`;
  865.     int $direction = `optionVar -q rebuildSurfaceDirection`;
  866.     int $keepControlPoints = `optionVar -q rebuildSurfaceKeepControlPoints`;
  867.     int $keepCornerPts = `optionVar -q rebuildSurfaceKeepCornerPoints`;
  868.     int $keepNumSpans = `optionVar -q rebuildSurfaceKeepNumSpans`;
  869.     int $srfUseGlobalTol = `optionVar -q rebuildSurfaceUseGlobalTolerance`;
  870.     float $srfLocalTol = `optionVar -q rebuildSurfaceLocalTolerance`;
  871.     int $polys = `optionVar -q rebuildSurfacePolys`;
  872.  
  873.     if( $keepNumSpans ) {
  874.         $srfNumSpansU = 0;
  875.         $srfNumSpansV = 0;
  876.     }
  877.  
  878.     performRebuildSurfaceSet( $doHistory, $replaceOriginal,
  879.                               $rebuildType, $globalTol,
  880.                               $srfNumSpansU, $srfNumSpansV,
  881.                               $srfDegreeU, $srfDegreeV,
  882.                               $endKnots,
  883.                               $keepParmRange, $keepCornerPts,
  884.                               $keepControlPoints, $direction,
  885.                               $srfUseGlobalTol, $srfLocalTol,
  886.                               $polys );
  887. }
  888.  
  889. //
  890. //  Procedure Name:
  891. //      assembleCmd
  892. //
  893. //  Description:
  894. //        Construct the command that will apply the option box values.
  895. //
  896. //  Input Arguments:
  897. //      None.
  898. //
  899. //  Return Value:
  900. //      None.
  901. //
  902. proc string assembleCmd()
  903. {
  904.     string $cmd = "performRebuildSurfaceSet";
  905.  
  906.     setOptionVars(false);
  907.  
  908.     int $doHistory = `constructionHistory -q -tgl`;
  909.     int $replaceOriginal = !`optionVar -q rebuildSurfaceKeepOriginal`;
  910.     int $rebuildType = `optionVar -q rebuildSurfaceType`;
  911.     float $globalTol = `optionVar -q positionalTolerance`;;
  912.  
  913.     int $srfNumSpansU = `optionVar -q rebuildSurfaceTypeUniformNumSpansU`;
  914.     int $srfNumSpansV = `optionVar -q rebuildSurfaceTypeUniformNumSpansV`;
  915.     int $srfDegreeU = `optionVar -q rebuildSurfaceTypeUniformDegreeU`;
  916.     int $srfDegreeV = `optionVar -q rebuildSurfaceTypeUniformDegreeV`;
  917.     int $keepParmRange = `optionVar -q rebuildSurfaceKeepRange`;
  918.     int $endKnots = `optionVar -q rebuildSurfaceEndKnots`;
  919.     int $direction = `optionVar -q rebuildSurfaceDirection`;
  920.     int $keepControlPoints = `optionVar -q rebuildSurfaceKeepControlPoints`;
  921.     int $keepCornerPts = `optionVar -q rebuildSurfaceKeepCornerPoints`;
  922.     int $keepNumSpans = `optionVar -q rebuildSurfaceKeepNumSpans`;
  923.     int $srfUseGlobalTol = `optionVar -q rebuildSurfaceUseGlobalTolerance`;
  924.     float $srfLocalTol = `optionVar -q rebuildSurfaceLocalTolerance`;
  925.     int $polys = `optionVar -q rebuildSurfacePolys`;
  926.  
  927.     if( $keepNumSpans ) {
  928.         $srfNumSpansU = 0;
  929.         $srfNumSpansV = 0;
  930.     }
  931.  
  932.     $cmd = ( $cmd + " " +
  933.              $doHistory + " " +
  934.              $replaceOriginal + " " +
  935.              $rebuildType + " " +
  936.              $globalTol + " " +
  937.              $srfNumSpansU + " " +
  938.              $srfNumSpansV + " " +
  939.              $srfDegreeU + " " +
  940.              $srfDegreeV + " " +
  941.              $endKnots + " " +
  942.              $keepParmRange + " " +
  943.              $keepCornerPts + " " +
  944.              $keepControlPoints + " " +
  945.              $direction + " " +
  946.              $srfUseGlobalTol + " " +
  947.              $srfLocalTol + " " +
  948.              $polys );
  949.     return $cmd;
  950. }
  951.  
  952. //
  953. //  Procedure Name:
  954. //      performRebuildSurface
  955. //
  956. //  Description:
  957. //        Perform the rebuildSurface command using the corresponding 
  958. //        option values.  This procedure will also show the option box
  959. //        window if necessary as well as construct the command string
  960. //        that will invoke the rebuildSurface command with the current
  961. //        option box values.
  962. //
  963. //  Input Arguments:
  964. //      0 - Execute the command.
  965. //      1 - Show the option box dialog.
  966. //      2 - Return the command.
  967. //
  968. //  Return Value:
  969. //      None.
  970. //
  971.  
  972. global proc string performRebuildSurface(int $action, string $goToTool)
  973. {
  974.     int $inTheTool = false;
  975.     if( 3 == $action ) {
  976.         $action = 1;
  977.         $inTheTool = true;
  978.     }
  979.  
  980.     string $cmd = "";
  981.     switch ($action) {
  982.  
  983.       case 0:
  984.         setOptionVars(false);
  985.         $cmd = `assembleCmd`;
  986.         eval($cmd);
  987.         break;
  988.  
  989.       case 1:
  990.         rebuildSurfaceOptions( $inTheTool, $goToTool );
  991.         break;
  992.  
  993.       case 2:
  994.       default:
  995.         setOptionVars (false);
  996.         $cmd = `assembleCmd`;
  997.         break;
  998.     }
  999.     return $cmd;
  1000. }
  1001.  
  1002.